﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LGE;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace EggCatcher
{
    class Egg : GameObject
    {
        static int colorQty = 6;
        static Dictionary<int, Texture2D> EggTextures = new Dictionary<int, Texture2D>();
        static Egg() { for (int i = 0; i < colorQty; ++i) EggTextures.Add(i, Engine.Load<Texture2D>("Images\\Eggs\\" + i)); }
        public static Texture2D GetRandomTexture() { return EggTextures[Rand.Next(colorQty)]; }

        int velocity = 3;

        public Egg(GameScreen gs, Vector2 pos)
            : base(gs, GetRandomTexture())
        {
            position = pos;
        }

        public override void Update(GameTime gameTime)
        {
            position += Direction.Down * velocity;
            if (position.Y > Engine.viewport.Height) alive = false;
            if (Collision((gameScreen as PlayScreen).basket))
            {
                if (alive) (gameScreen as PlayScreen).EggHitBasket();
                alive = false;
            }
        }
    }
}
